package com.czy.owner.api;

import android.text.TextUtils;

import com.czy.owner.db.UserHelper;
import com.czy.owner.global.Constants;
import com.czy.owner.net.api.BaseApi;
import com.czy.owner.net.listener.HttpOnNextListener;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

import java.util.HashMap;

import retrofit2.Retrofit;
import rx.Observable;

/**
 * Created by hep on 2018/1/09.
 */

public class HotShopSupplierListApi extends BaseApi {
    private String page;
    private String size;
    private String storeId;
    private String categoryId;
    private String goodsBrandId;
    private String goodsName;
    private String queryField;
    private String session;
    private String supplierId;
    private String goodsActivityId;

    public String getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(String supplierId) {
        this.supplierId = supplierId;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public String getStoreId() {
        return storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    public String getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(String categoryId) {
        this.categoryId = categoryId;
    }

    public String getGoodsBrandId() {
        return goodsBrandId;
    }

    public void setGoodsBrandId(String goodsBrandId) {
        this.goodsBrandId = goodsBrandId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getQueryField() {
        return queryField;
    }

    public void setQueryField(String queryField) {
        this.queryField = queryField;
    }

    public String getSession() {
        return session;
    }

    public void setSession(String session) {
        this.session = session;
    }

    public String getGoodsActivityId() {
        return goodsActivityId;
    }

    public void setGoodsActivityId(String goodsActivityId) {
        this.goodsActivityId = goodsActivityId;
    }

    public HotShopSupplierListApi(HttpOnNextListener listener, RxAppCompatActivity rxAppCompatActivity, String page) {
        super(listener, rxAppCompatActivity);
        setShowProgress(false);
        setCache(true);
        setMothed(UserHelper.getInstance().getUserAccount() + Constants.OWN_HOTSHOP_GETSUPGOODSLIST);//相当于缓存保存的Key
        setCookieNetWorkTime(0);//有网缓存0s,在0s内点击无效
        setCookieNoNetWorkTime(24 * 60 * 60 * 7);//无网缓存7天
        setmCachePage(page);
    }


    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpPostService service = retrofit.create(HttpPostService.class);
        HashMap<String, Object> map = new HashMap<>();
        if (!TextUtils.isEmpty(getSession())) {
            map.put("session", getSession());
            map.put("storeId", getStoreId());
        }
        map.put("page", getPage());

        map.put("size", getSize());
        map.put("queryField", getQueryField());
        map.put("supplierId", getSupplierId());
        if (!TextUtils.isEmpty(getGoodsName())) {
            map.put("goodsName", getGoodsName());
        }
        if (!TextUtils.isEmpty(getGoodsBrandId())) {
            map.put("goodsBrandId", getGoodsBrandId());
        }
        if (!TextUtils.isEmpty(getCategoryId())) {
            map.put("categoryId", getCategoryId());
        }

        if (!TextUtils.isEmpty(getGoodsActivityId())) {
            map.put("goodsActivityId", getGoodsActivityId());
        }
        return service.getSupGoodsListApi(map);
    }
}
